package com.jeecg.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.base.util.HtmlUtil;
import com.base.web.BaseAction;
import com.google.gson.Gson;
import com.jeecg.entity.Highchart;

@Controller
@RequestMapping("/demo")
public class LogController extends BaseAction {

	@RequestMapping(params = "line")
	public ModelAndView line(HttpServletRequest request) {
		return new ModelAndView("demo/userBroswerLine");
	}
	
	
	@RequestMapping(value = "/getBroswerBar")
	//@ResponseBody
	public  void getBroswerBar(HttpServletRequest request, HttpServletResponse response) {
		List<Highchart> ls = new ArrayList<Highchart>();
		Highchart hg = new Highchart();
		hg.setName("用户浏览器统计分析");
		hg.setType("line");
		List lt = new ArrayList();
		Map<String, Object> map= new HashMap<String, Object>();
		map.put("name", "Chrome");
		map.put("y", 42);
		map.put("percentage", 35.0);
		lt.add(map);
		map= new HashMap<String, Object>();
		map.put("name", "Firefox");
		map.put("y", 11);
		map.put("percentage", 9.166666666666666);
		lt.add(map);
		map= new HashMap<String, Object>();
		map.put("name", "MSIE 8.0");
		map.put("y", 31);
		map.put("percentage", 25.833333333333336);
		lt.add(map);
		map= new HashMap<String, Object>();
		map.put("name", "rv:11.0");
		map.put("y", 2);
		map.put("percentage", 1.6666666666666667);
		lt.add(map);
		hg.setData(lt);
		ls.add(hg);
		Gson jsonResp = new Gson();
		//return jsonResp.toJson(ls);
		//return jsonResp.toJson(ls);
		HtmlUtil.writerJson(response, ls);
	}
	
}
